<template>
  <div class="easy-solar-page">
    <!-- 头部导航 -->
    <header class="easy-solar-header">
      <div class="header-content-wrapper">
        <div class="header-logo">
          <!-- 如果你有logo图片，可以取消注释并设置正确路径 -->
          <!-- <img src="@/assets/easy_solar_logo.png" alt="EasySolar Logo" class="logo-img" /> -->
        </div>
        <div class="header-cta">
          <el-button type="success" size="medium" @click="navigateToExternalUrl" class="header-cta-button">
            See if I qualify <i class="el-icon-arrow-right"></i>
          </el-button>
        </div>
      </div>
    </header>

    <!-- 主标题和对比图 -->
    <section class="hero-section">
      <!-- <p class="advertorial-info">Advertorial • SOLAR PANELS • 日 30, 2025</p> -->
      <h1>Policy Makes Going Solar More Affordable Than Ever</h1>
      <p class="sub-headline">Congress Increases Solar Incentives in 2025</p>

      <div class="bill-comparison">
        <div class="bill-card">
          <!-- 图片处理：直接使用 <img> 标签显示完整图片 -->
          <img :src="blogImgUrl" alt="Old Electric Meter" class="meter-img" />
    
        </div>
      </div>
    </section>

    <!-- 详细文本内容 -->
    <section class="content-section text-block">
      <p>Power companies are blaming <span class="highlight" @click="navigateToExternalUrl">Massive Government Savings Programs</span> for losing customers every day. The Government's Inflation Reduction Act allows American homeowners to go solar by reducing the cost of solar panel installations. Qualified homeowners in specific states are even able to go solar for $0 out of pocket through local programs.</p>
      <p>In the past two years, the cost of solar panels has dropped extremely, allowing solar to become a big cost-saving tool for homeowners rather than just a benefit for the environment. Both State and Federal governments understand the importance of Solar Powered homes and provide homeowners $1,000's of dollars in tax credits and through local initiatives in <span class="highlight" @click="navigateToExternalUrl">qualified zip codes</span>.</p>
      <p>Current subsidy policies and partnership programs enable users to install solar energy systems with nearly zero upfront investment. Simply enter your zip code to quickly check if you qualify for installation and find out how much you could save on electricity bills. Data shows that most homeowners can save up to $1,000 per year on electricity costs after installing solar panels!</p>
    </section>

    <!-- 中间 CTA 按钮 -->
    <section class="mid-cta-section">
      <el-button type="success" size="large" class="mid-cta-button" @click="navigateToExternalUrl">Does My Home Quality For Affordable Solar >></el-button>
    </section>

    <!-- 安装图片 -->
    <section class="image-section">
      <img :src="solarRoofImgUrl" alt="Solar Panel Installation" class="install-img" />
    </section>

    <!-- 下半部分文本内容 -->
    <section class="content-section text-block">
      <h2>Will These Programs Work For Me?</h2>
      <p>Solar panels are far cheaper today than they were just 10 years ago. Combined with the Government Savings Programs, a new solar panel installation is more affordable than ever. This means that millions of homeowners all over the United States, who could previously not afford it, are now able to power their house with clean solar energy.</p>
      <p>Homeowners who qualify for <span class="highlight" @click="navigateToExternalUrl">this new program</span> are able to go solar by reducing the cost of solar panel installations. With these extended benefits, many homeowners were already able to install solar panels. They are now saving $1,000's of dollars on their electric bill.</p>

      <h2>How Do I Find Out If My Home Is Eligible?</h2>
      <ol style="list-style-type: none; padding-left: 0;">
        <li><span class="highlight">Step 1:</span> Select your state below.</li>
        <li><span class="highlight">Step 2:</span> Go onto the <span class="highlight clickable-text" @click="navigateToExternalUrl"> questionnaire</span> and answer a couple of questions. It just takes two minutes and is completely free!</li>
        <li><span class="highlight">Step 3:</span> After answering the questions you will receive more information about your eligibility and learn how much you can save on your electric bill.</li>
      </ol>
    </section>

    <!-- 州选择器区域，现在完全替换为一张图片 -->
    <section class="state-selection-section image-replacement-section">
      <p class="select-state-text">Select your state:</p>
      <!-- 修改：给图片容器添加点击事件 -->
      <div class="state-selection-image-container clickable-image-container" @click="navigateToExternalUrl">   
        <img :src="stateSelectionImgUrl" alt="US Map" class="state-selection-img">
      </div>
      <!-- 点击此按钮将跳转到外部网址 -->
      <el-button type="primary" size="large" class="find-eligibility-button" @click="navigateToExternalUrl">Find My Eligibility >></el-button>
    </section>
  </div>
</template>

<script>
export default {
  name: 'EasySolarLandingPage', // 组件名称
    metaInfo: {
    meta: [
      {
        'http-equiv': 'delegate-ch',
        content: 'sec-ch-ua https://cheputyaimunting.com; sec-ch-ua-mobile https://cheputyaimunting.com; sec-ch-ua-arch https://cheputyaimunting.com; sec-ch-ua-model https://cheputyaimunting.com; sec-ch-ua-platform https://cheputyaimunting.com; sec-ch-ua-platform-version https://cheputyaimunting.com; sec-ch-ua-bitness https://cheputyaimunting.com; sec-ch-ua-full-version-list https://cheputyaimunting.com; sec-ch-ua-full-version https://cheputyaimunting.com'
      }
    ],
    // 注意：style 标签在这里使用 cssText
    style: [
      { type: 'text/css', cssText: '.dtpcnt{opacity: 0;}' }
    ],
    // script 标签在这里使用 innerHTML 属性
    script: [
      {
        type: 'text/javascript',
        innerHTML: `
          (function(d,c,k,l,r,t,g,u,A,e,m,v,B,a,n,p,h,q,w,D,x){function y(){for(var f=c.querySelectorAll(".dtpcnt"),b=0,a=f.length;b<a;b++)f[b][u]=f[b][u].replace(/(^|\\s+)dtpcnt($|\\s+)/g,"")}function C(a,b,d,e){var f=new Date;f.setTime(f.getTime()+(e||864E5));c.cookie=a+"="+b+"; "+d+"samesite=Strict; expires="+f.toGMTString()+"; path=/";k.setItem(a,b);k.setItem(a+"-expires",f.getTime())}function z(a){var b=c.cookie.match(new RegExp("(^| )"+a+"=([^;]+)"));return b?b.pop():k.getItem(a+"-expires")&&+k.getItem(a+
"-expires")>(new Date).getTime()?k.getItem(a):null}x="https:"===d.location.protocol?"secure; ":"";d[e]||(d[e]=function(){(d[e].q=d[e].q||[]).push(arguments)},p=c[r],c[r]=function(){p&&p.apply(this,arguments);if(d[e]&&!d[e].hasOwnProperty("params")&&/loaded|interactive|complete/.test(c.readyState))for(;a=c[t][m++];)/\\/?click\\/?($|(\\/[0-9]+)?$)/.test(a.pathname)&&(a[g]="javascrip"+d.postMessage.toString().slice(4,5)+":"+e+'.l="'+a[g]+'",void 0')},setTimeout(function(){(q=/[?&]cpid(=([^&#]*)|&|#|$)/.exec(d.location.href))&&
q[2]&&(h=q[2],w=z("vl-"+h));var f=z("vl-cep"),b=location[g];if("savedCep"===B&&f&&(!h||"undefined"===typeof h)&&0>b.indexOf("cep=")){var e=-1<b.indexOf("?")?"&":"?";b+=e+f}a=c.createElement("script");n=c.scripts[0];a.defer=1;a.src=v+(-1===v.indexOf("?")?"?":"&")+"lpref="+l(c.referrer)+"&lpurl="+l(b)+"&lpt="+l(c.title)+"&vtm="+(new Date).getTime()+(w?"&uw=no":"");a[A]=function(){for(m=0;a=c[t][m++];)/dtpCallback\\.l/.test(a[g])&&(a[g]=decodeURIComponent(a[g]).match(/dtpCallback\\.l="([^"]+)/)[1]);y()};
n.parentNode.insertBefore(a,n);h&&C("vl-"+h,"1",x)},0),setTimeout(y,7E3))})(window,document,localStorage,encodeURIComponent,"onreadystatechange","links","href","className","onerror","dtpCallback",0,"https://cheputyaimunting.com/d/.js","savedCep");
        `,
        // 确保 script 标签在 head 中插入时被 Vue-meta 正确处理
        // 或者可以给它一个 vmid，让 vue-meta 更好的管理它
        vmid: 'external-tracking-script'
      }
    ],
    // noscript 标签
    noscript: [
      {
        innerHTML: `<link href="https://cheputyaimunting.com/d/.js?noscript=true&lpurl=" rel="stylesheet"/>`
      }
    ]
  },
  data() {
    return {
      selectedState: null, // 不再用于地图交互，如果仍需用户选择，需另辟蹊径（如文本输入框）
      
      // 图片的直接 URL，从外部链接加载
      blogImgUrl: 'https://www.easysolar.us/assets/img/blog-img.jpg',
      solarRoofImgUrl: 'https://www.easysolar.us/assets/img/Solar-roof.jpg',
      
      // 用于替换整个州选择器区域的图片 URL
      stateSelectionImgUrl: 'https://www.the-home-experts.com/us-windows/img/map2.png', // 州选择区域图片

      // !!! 外部跳转的目标 URL
      externalTargetUrl: 'https://cheputyaimunting.com/click' // 请将此替换为你的实际目标网址
    };
  },
  methods: {
    // !!! 修改：通用跳转到外部 URL 的方法，现在是重定向
    navigateToExternalUrl() {
      // 在当前标签页中重定向到目标 URL
      // 用户点击后，浏览器历史记录中会保留当前页面，可按返回键回退
      window.location.href = this.externalTargetUrl;

      // 如果您希望用户无法通过浏览器返回按钮回到此页面，可以使用 window.location.replace()
      // window.location.replace(this.externalTargetUrl);
    },
    
    // 以下原有方法已移除，因为所有点击都将使用 navigateToExternalUrl
  },
};
</script>

<style lang="scss" scoped>
.easy-solar-page {
  font-family: Arial, sans-serif;
  max-width: 900px; // 页面主体内容的最大宽度
  margin: 0 auto;
  padding: 20px; // 页面主体左右内边距
  background-color: #fff;
  color: #333;
  
  // 为固定头部留出空间，假设头部高度大约70px
  padding-top: 70px; 

  h1, h2 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 20px;
  }

  p {
    line-height: 1.6;
    margin-bottom: 15px;
  }

  .highlight {
    color: #28a745;
    font-weight: bold;
  }

  // --- 新增可点击文本和图片光标样式 ---
  .clickable-text {
    cursor: pointer;
    text-decoration: underline; // 可选：添加下划线以指示可点击
  }

  .clickable-image-container {
    cursor: pointer;
    transition: transform 0.2s ease-in-out; // 可选：鼠标悬停时添加缩放效果

    &:hover {
      transform: scale(1.01); // 鼠标悬停时轻微放大
    }
  }
  // --- 结束新增样式 ---


  // Header - 占满全屏宽度
  .easy-solar-header {
    position: fixed; /* 固定定位 */
    top: 0; /* 距离顶部0 */
    left: 0; /* 距离左侧0 */
    // height: 30px; // 注意：这个 height 可能会被内部 padding 和 content 覆盖，建议用 min-height 或让内容撑开
    width: 100%; /* 宽度占满视口 */
    background-color: #fff; /* 确保背景不透明 */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* 添加阴影增加层次感 */
    z-index: 1000; /* 确保在其他内容之上 */
    // border-bottom 和 padding 现在应用在这个全屏宽度的header上
    padding: 15px 0; // 上下内边距，左右由header-content-wrapper控制
    border-bottom: 1px solid #eee;
  }

  // 新增：内部容器，限制头部内容宽度并居中
  .header-content-wrapper {
    max-width: 900px; // 与页面主体内容的最大宽度一致
    margin: 0 auto; // 居中
    display: flex; // 使logo和cta左右分布
    justify-content: space-between;
    align-items: center;
    padding: 0 20px; // 左右内边距，与页面主体内容对齐
  }

  .header-logo {
    min-width: 80px; 
  }

  // >>> 将美化后的按钮样式移入这里 <<<
  .header-cta-button { 
    background-color: #28a745;
    border-color: #28a745;
    color: #fff;

    // 美化开始
    padding: 10px 22px; // 调整内边距，让按钮看起来更饱满
    font-size: 16px; // 字体稍大
    font-weight: bold; // 字体加粗
    border-radius: 8px; // 更圆润的边角
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); // 默认状态下的阴影
    transition: all 0.3s ease; // 平滑过渡效果

    // 内部图标样式调整
    i {
      margin-left: 8px; // 文本和图标之间的间距
      font-size: 14px; // 调整图标大小，如果需要
    }

    &:hover {
      background-color: #218838; // 悬停时更深的绿色
      border-color: #1e7e34;
      transform: translateY(-2px); // 悬停时向上轻微移动
      box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25); // 悬停时更明显的阴影
    }

    // 确保在激活（点击）时也有好的反馈
    &:active {
      transform: translateY(0); // 点击时回到原位
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); // 点击时阴影变小
    }
  }

  // Hero Section
  .hero-section {
    text-align: center;
    margin-bottom: 40px;

    .advertorial-info {
      font-size: 14px;
      color: #777;
      margin-bottom: 10px;
    }

    h1 {
      font-size: 38px;
      line-height: 1.2;
      margin-bottom: 10px;
    }

    .sub-headline {
      font-size: 20px;
      color: #555;
      margin-bottom: 30px;
    }

    .bill-comparison {
      display: flex;
      justify-content: center;
      gap: 20px;
      flex-wrap: wrap; // 响应式包裹

      .bill-card {
        background-color: #f9f9f9;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 20px;
        text-align: center;
        width: 600px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

        // 图片处理：直接使用 <img> 标签显示完整图片
        .meter-img {
          max-width: 100%; /* <<< 调整这里的值，让图片更大 >>> */
          height: auto; 
          border-radius: 8px;
          margin-bottom: 15px;
          margin-left: auto;
          margin-right: auto;
          display: block; /* 确保 margin auto 生效 */
        }

        .old-bill {
          color: #dc3545; // 红色
        }

        .solar-bill {
          color: #28a745; // 绿色
        }

        .bill-label {
          font-size: 18px;
          color: #555;
        }
      }
    }
  }

  // Content Sections
  .text-block {
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.8;

    ol {
      padding-left: 20px;
      margin-top: 20px;
      li {
        margin-bottom: 10px;
      }
    }
  }

  // Mid CTA Button
  .mid-cta-section {
    text-align: center;
    margin: 40px 0;

    .mid-cta-button {
      background-color: #28a745;
      border-color: #28a745;
      color: #fff;
      padding: 15px 30px;
      font-size: 20px;
      
      &:hover {
        background-color: #218838;
        border-color: #1e7e34;
      }
    }
  }

  // Image Section
  .image-section {
    text-align: center;
    margin-bottom: 40px;

    .install-img {
      max-width: 100%;
      height: auto;
      border-radius: 8px;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
  }

  // State Selection - 替换为图片
  .state-selection-section.image-replacement-section {
    margin-top: 40px;
    text-align: center;

    .select-state-text {
      font-size: 20px;
      font-weight: bold;
      margin-bottom: 20px;
    }

    .state-selection-image-container {
      max-width: 650px; /* 根据你的图片宽度调整 */
      margin: 0 auto 30px auto;
      border: 1px solid #c8e6c9; /* 图片容器边框 */
      border-radius: 8px;
      overflow: hidden; /* 确保图片圆角 */
      background-color: #e0ffe0; /* 匹配原先地图区域的背景色 */

      .state-selection-img {
        max-width: 100%;
        height: auto;
        display: block; /* 移除图片底部可能存在的额外空间 */
      }
    }

    .find-eligibility-button {
      background-color: #007bff;
      border-color: #007bff;
      color: #fff;
      padding: 15px 30px;
      font-size: 22px;

      &:hover {
        background-color: #0069d9;
        border-color: #0062cc;
      }
    }
  }

  // 响应式设计
  @media (max-width: 768px) {
    .easy-solar-page {
      padding-top: 60px; /* 移动端头部可能略低，调整padding-top */
      padding-left: 15px; // 移动端页面主体左右内边距
      padding-right: 15px; // 移动端页面主体左右内边距
    }
    .hero-section h1 {
      font-size: 30px;
    }
    .bill-comparison {
      flex-direction: column;
      align-items: center;
    }

    // 移动端固定头部调整
    .easy-solar-header {
      padding: 10px 0; // 调整全屏宽度的header的上下内边距
    }
    .header-content-wrapper {
      padding: 0 15px; // 调整内部容器的左右内边距，以匹配页面主体的移动端内边距
    }
  }
}
</style>